<template>
  <div>
    请使用支付宝扫码付款:
    <canvas id="q"></canvas>
    <br />订单如下:
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column fixed prop="name" label="药片姓名" width="150"></el-table-column>
      <el-table-column prop="username" label="患者姓名" width="150"></el-table-column>
      <el-table-column prop="phone" label="患者电话" width="150"></el-table-column>
      <el-table-column prop="num" label="药片数量" width="150"></el-table-column>
      <el-table-column prop="price" label="药片价格" width="150"></el-table-column>
      <el-table-column prop="total" label="药片总价" width="150"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from "axios";
export default {
  methods: {
    getList() {
      var $this = this;
      this.axios({
        method: "post",
        url: "http://localhost:9999/upms/tCar/selectBYGetCar",
        params: {
          access_token: localStorage.getItem("access_token")
        }
      }).then(function(res) {
        $this.tableData = res.data.obj;
      });
    }
  },
  data() {
    return {
      tableData: [],
      addflag: false,
    };
  },
  mounted() {
    this.getList();
    var canvas = document.getElementById("q");
    var $this = this;
    this.axios({
      method: "post",
      url: "http://localhost:9999/biz/alibaba/pay/createPayOrder",
      params: {
        access_token: localStorage.getItem("access_token"),
        orderNo: new Date().getTime()
      }
    }).then(function(res) {
      console.log("生成支付宝扫码二维码返回信息为{}", res);
      $this.QRCode.toCanvas(canvas, res.data.obj, function(error) {
        if (error) {
          console.error(error);
        }
        console.log("QRCode success!");
      });
    });
  }
};
</script>
